<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output omit-xml-declaration ="yes" method ="html"/>

	<xsl:variable name ="LocalMachineName" select ="//SPTraceViewLog/@computerName" />
	<xsl:template match ="*">
		<html>
			<body bgcolor="GhostWhite">
				<h3>
					Computer <xsl:value-of select="$LocalMachineName"/>, Date <xsl:value-of select="//SPTraceViewLog/@date"/>
				</h3>
				<table border="1" cellspacing="0" cellpadding="3" bordercolor="#000098">
					<tr bgcolor="#F4F4FF">
						<th>Server</th>
						<th>Time</th>
						<th>Severity</th>
						<th>Product</th>
						<th>Category</th>
						<th>Message</th>
					</tr>
					<xsl:for-each select ="//SPTraceViewLog/TraceEntry">
						<xsl:call-template name ="FormatTraceEntry">
							<xsl:with-param name ="TraceNode" select ="." />
						</xsl:call-template>
					</xsl:for-each>
				</table>
			</body>
		</html>
	</xsl:template>

	<xsl:template name ="FormatTraceEntry">
		<xsl:param name ="TraceNode" />
		<xsl:element name ="tr">
			<xsl:attribute name ="bgcolor">
				<xsl:choose>
					<xsl:when test ="$TraceNode/@severity = 'CriticalEvent'">#FFE0E0</xsl:when>
					<xsl:when test ="$TraceNode/@severity = 'Exception'">#FFE0E0</xsl:when>
					<xsl:when test ="$TraceNode/@severity = 'Unexpected'">#FFEEEE</xsl:when>
					<xsl:when test ="$TraceNode/@severity = 'Assert'">#FFEEEE</xsl:when>
					<xsl:when test ="$TraceNode/@severity = 'High'">#FFEEEE</xsl:when>
					<xsl:when test ="$TraceNode/@severity = 'Unassigned'">#FFFCE4</xsl:when>
					<xsl:when test ="$TraceNode/@severity = 'WarningEvent'">#FFFCE4</xsl:when>
					<xsl:when test ="$TraceNode/@severity = 'Medium'">#FFFCE4</xsl:when>
					<xsl:when test ="$TraceNode/@severity = 'InformationEvent'">#E4FFE4</xsl:when>
					<xsl:when test ="$TraceNode/@severity = 'Monitorable'">#E4FFE4</xsl:when>
					<xsl:when test ="$TraceNode/@severity = 'Verbose'">#E4FFE4</xsl:when>
					<xsl:otherwise>white</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			<td valign="time">
				<xsl:choose>
					<xsl:when test ="$TraceNode/@serverName = 'localhost'">
						<xsl:value-of select ="$LocalMachineName"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select ="$TraceNode/@serverName"/>
					</xsl:otherwise>
				</xsl:choose>
			</td>			
			<td valign="time">
				<xsl:value-of select ="$TraceNode/@time"/>
			</td>
			<td valign="top">
				<xsl:value-of select ="$TraceNode/@severity"/>
			</td>
			<td valign="top" nowrap="nowrap">
				<xsl:value-of select ="$TraceNode/@product"/>
			</td>
			<td valign="top" nowrap="nowrap">
				<xsl:value-of select ="$TraceNode/@category"/>
			</td>
			<td valign="top">
				<xsl:value-of select ="$TraceNode/text()"/>
			</td>
		</xsl:element>
	</xsl:template>
</xsl:stylesheet>